package com.bootdo.mall.service;

import com.bootdo.common.utils.DateUtils;
import com.bootdo.common.utils.Hog;
import com.bootdo.haojiangboutils.MapBuild;
import com.bootdo.mall.domain.MallGood;
import com.bootdo.mall.domain.MallOrder;
import com.bootdo.mall.domain.MallOrderLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;

@Service
public class OverOrderUpadateService implements Runnable{


    public OverOrderUpadateService(){
        new Thread(this).start();
    }

    @Autowired
    private MallOrderService mallOrderService;
    @Autowired
    private MallOrderLogService mallOrderLogService;
    @Autowired
    private MallGoodService mallGoodService;



    @Override
    public void run() {
        while (true){
            try {
                Hog.e("确认收货的线程正在执行");
                Thread.sleep(1000*60);
                if(null != mallOrderService && null != mallGoodService && null != mallOrderLogService){
                    List<MallOrder> list =    mallOrderService.list(MapBuild.getInstand().setKV("overOrderTime", System.currentTimeMillis())
                            .setKV("payStatus", 2));
                    //如果配送成功的订单 大于 0 个
                    mallOrderService.overOrderByOrderId(list);
                }
            }catch (Exception e){
                e.printStackTrace();
            }

        }
    }



}
